package com.bwie.home.backstage.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.home.backstage.entity.HousesFloorEntity;
import com.bwie.home.backstage.service.HousesFloorService;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.R;



/**
 * 
 *
 * @author sy
 * @email sunlightcs@gmail.com
 * @date 2021-09-10 09:46:41
 */
@RestController
@RequestMapping("backstage/housesfloor")
public class HousesFloorController {
    @Autowired
    private HousesFloorService housesFloorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = housesFloorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{floorId}")
    public R info(@PathVariable("floorId") Integer floorId){
		HousesFloorEntity housesFloor = housesFloorService.getById(floorId);

        return R.ok().put("housesFloor", housesFloor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HousesFloorEntity housesFloor){
		housesFloorService.save(housesFloor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HousesFloorEntity housesFloor){
		housesFloorService.updateById(housesFloor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] floorIds){
		housesFloorService.removeByIds(Arrays.asList(floorIds));

        return R.ok();
    }

}
